<?php
    class admin_controller_api_login extends controller
    {
        private $member;

        public function run()
        {
            $name     = p('name');
            $password = md5(p('password'));

            $this->member = new admin_model_member();
            $res      = $this->member->validate($name, $password);

            if ($res)
            {
                $this->login_init($name, $password);
                echo 'success';
            }

            exit;
        }

        public function login_init($name, $password)
        {
            setcookie('name',     $name,     time()+3600);
            setcookie('password', $password, time()+3600);

            $administrator_information = $this->member->through_username_get_information($name);

            $_SESSION['administrator_information'] = $administrator_information;
        }
    }